attribute vec3	inVertex;
attribute vec2	inUV;

uniform lowp  float     fWaveOffset;
uniform mat4            mvpMatrix;
uniform mat4            mvMatrix;
//uniform mediump float   waveOffset;

varying lowp    vec3    fFogIntensity;
varying lowp   vec2     fTexCoord;

void main(void)
{
    vec3 v = inVertex;
    
    if (v.y>0.0 && fWaveOffset!=0.0) {
        v.x += fWaveOffset;
    }
    
	gl_Position = mvpMatrix * vec4(v, 1.0);
    
    //fLightDirection = normalize(lightDirection);
    
    //fDiffuse = max(dot(normalize(inNormal), fLightDirection), 0.0);
    
    fTexCoord = inUV;
    
    	
    // compute fog
    	
	// transform position to view space as we need the distance to the eye for fog
	highp vec3 viewPos = vec3(mvMatrix * vec4(inVertex, 1.0));
	highp float eyeDist = length(viewPos);
    // Fog function is exponential squared.
    highp float scaledDist = eyeDist * 0.0025;
    //scaledDist *= scaledDist;
    highp float f = exp2(-scaledDist);
    // clamp the intensity within a valid range
	fFogIntensity = vec3(clamp(f, 0.0, 1.0));
}
